<?php

namespace App\Models;

class Config extends Model
{
    use Traits\ModelCacheKey;

    protected $guarded = [];

    protected $casts = [
        'value' => 'json',
    ];

    public static $FlagMap = [
        'points_num_config' => '积分获取数量配置',
    ];


    /**
     * 查询作用域
     */
    public function scopePointsNum($query, $id = 'g')
    {
        $data = $query->where('flag', 'points_num_config')->value('value');

        return data_get($data, $id, 0);
    }
}
